home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / ultqsrc.zip / SHELLS.QC < prev    next >
Text File  |  1996-08-30  |  3KB  |  97 lines

  1. //====================================================================
  2. //
  3. // SHOTGUN SHELLS            by: Perecli Manole AKA Bort
  4. //              Shell .mdl & .wav by: Steve Bond
  5. //
  6. //====================================================================
  7. // Aside from this new file, the following are the modifications
  8. // done to id's original source files:
  9. //--------------------------------------------------------------------
  10. // File: Progs.src
  11. // Location: before the "holo.qc" line
  12. // Added: shells.qc
  13. //--------------------------------------------------------------------
  14. // File: Weapons.qc
  15. // Procedure: W_Precache
  16. // Location: last line
  17. // Added: precache_sound ("weapons/shellhit.wav"); // shotgun shells
  18. //--------------------------------------------------------------------
  19. // File: World.qc
  20. // Procedure: worldspawn
  21. // Location: at the end of all precache model definitions
  22. // Added: precache_model ("progs/shell.mdl");
  23. //--------------------------------------------------------------------
  24. // File: Weapons.qc
  25. // Procedure: W_FireShotgun 
  26. // Location: before "FireBullets (6, dir, '0.04 0.04 0');" line
  27. // Added: SpawnShell(); 
  28. //--------------------------------------------------------------------
  29. // File: Weapons.qc
  30. // Procedure: W_FireSuperShotgun
  31. // Location: before "FireBullets (14, dir, '0.14 0.08 0');" line
  32. // Added: SpawnShell(); SpawnShell(); 
  33. //--------------------------------------------------------------------
  34.  
  35.  
  36. float () crandom;   // prototype
  37.  
  38.  
  39. //--------------------------------------------------------------------
  40. // Plays hit sound when shell hits hard surface if not stuck in loop
  41. //--------------------------------------------------------------------
  42. void() ShellHit =
  43. {
  44.     if (self.deadflag)                       // flag to stop repetitive loop sounds
  45.         return;
  46.     else
  47.     {
  48.         if (self.ltime > (time - 0.2))   // if last shell hit sound occured < than 2 frames ago
  49.         {
  50.                 self.deadflag = TRUE;    // mark shell as dead
  51.             return; 
  52.         }
  53.         else       
  54.         {
  55.             sound (self, CHAN_WEAPON, "weapons/shellhit.wav", 1, ATTN_NORM);
  56.             self.ltime = time;       // mark the time of the last sound
  57.         }
  58.     }
  59. };
  60.  
  61.  
  62. //--------------------------------------------------------------------
  63. // Displays shell and defines its dynamic manifestation
  64. //--------------------------------------------------------------------
  65. void() DropShell = 
  66. {
  67.     self.movetype = MOVETYPE_BOUNCE;
  68.     self.solid = SOLID_BBOX;
  69.         setmodel (self, "progs/shelcase.mdl");
  70.     setsize (self, VEC_ORIGIN, VEC_ORIGIN);   
  71.         makevectors (self.owner.v_angle);
  72.     setorigin (self, self.owner.origin + v_forward * 10 - v_right*10);    
  73.     self.velocity = v_forward*30 + crandom()*v_forward*30 + v_up*220 + crandom()*v_up*10 - v_right*50 + crandom()*v_right*20;
  74.         self.avelocity_x = crandom()*500;
  75.     self.avelocity_y = crandom()*500;
  76.     self.avelocity_z = crandom()*500;
  77.     self.touch = ShellHit;
  78.     self.nextthink = time + 20;
  79.     self.think = SUB_Remove;
  80.     self.ltime = time - 1;
  81.     self.deadflag = FALSE;
  82. };
  83.  
  84.  
  85. //--------------------------------------------------------------------
  86. // Spawns new shell entity but doesn't display it until reload time
  87. //--------------------------------------------------------------------
  88. void() SpawnShell=
  89. {
  90.         local entity shell;
  91.  
  92.     shell = spawn ();
  93.     shell.owner = self;
  94.     shell.nextthink = time + 0.4;         // delay shells until reload
  95.     shell.think = DropShell;
  96. };
  97.